/**
 * Created by nightgentle on 2016/9/4.
 */

var hashids = new Hashids("", 10);  //id混淆初始化

//提示弹框
function alertReturn(alertContent) {
    if(alertContent){
    var d = dialog({
        content: '<div class="ui-dialog-text">'+alertContent+'</div>',
        okValue: '确定',
        ok: function () {}
    });
    d.showModal();
    return false;
    }
}

//提示弹框
function alertTip(alertContent, alertTime, callback) {
    if(!alertTime) {
        alertTime = 3000;
    }
    var d = dialog({
        content: '<div class="ui-dialog-text">'+ alertContent +'</div>'
    });
    d.showModal();
    setTimeout(function () {
        d.close().remove();
        if (typeof(callback) != "undefined") {
            callback();
        }
    }, alertTime);
}

function request(paras) {
    var url = location.search;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {};
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof(returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}



function confirmInfo(alertContent) {
    var alertHtml = '<div class="submit-alert"><h3></h3><div class="sunbmit_main"><div class="sunbmit_text"></div><a href="javascript:;" class="btn-warning btn_submit green">是</a><a href="javascript:;" class="btn-warning btn_cancel red">否</a><a href="javascript:;" class="btn-warning btn_remove">取消</a></div></div>';
    $("html").append(alertHtml);
    $('.submit-alert .sunbmit_text').append(alertContent);
    $(".submit-alert").show();
    $(".sunbmit_main .btn_remove").click(function(){
        $(".submit-alert").remove();
    });
    $(".sunbmit_main .btn_cancel").click(function(){
        $(".submit-alert").remove();
    });
    $(".submit-alert .sunbmit_main .btn_submit").on("click",function(){
        $(".submit-alert").remove();
    });
}
function showLoading(vobj, vstr) {
    if (vstr === undefined) vstr = "数据加载中...";
    $(vobj).html(
        '<div style="text-align: center;margin: 20px 0 0 0;" id="loading"><img src=""><br>' +
        vstr + "</div>");
}

function hideLoading(vobj, needHide) {
    $(vobj).html("");
    if (needHide) {
        $(".j_loaded_content").removeClass("hidden");
    }
};
